package Operation;

import book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-07-04
 * Time: 22:33
 */
public class FindOperation implements Ioperation{
    @Override
    public void work(Booklist booklist) {
        System.out.println("查找书籍");
        System.out.println("请输入书籍名");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int currentsize = booklist.getUsedsize();
        for (int i = 0; i < currentsize; i++) {
            if(booklist.getBook(i).getName().equals(name)){
                System.out.println("找到了");
                System.out.println(booklist.getBook(i));
                return;
            }
        }
        //i>= currentsize 找不到
        System.out.println("没有这本书");
    }
}
